package com.example.demo.filters.inbound;

import com.netflix.zuul.filters.http.HttpInboundFilter;
import com.netflix.zuul.filters.http.HttpInboundSyncFilter;
import com.netflix.zuul.message.http.HttpRequestMessage;
import rx.Observable;

/**
 * @author sleepforests
 * Created on 2019-06-27
 */
public class Debug extends HttpInboundSyncFilter {
    @Override
    public int filterOrder() {
        return 20;
    }

    @Override
    public boolean shouldFilter(HttpRequestMessage request) {
        return "true".equalsIgnoreCase(request.getQueryParams().getFirst("debugRequest"));
    }

    @Override
    public HttpRequestMessage apply(HttpRequestMessage request) {
        request.getContext().setDebugRequest(true);
        request.getContext().setDebugRouting(true);

        return request;
    }

}
